package com.hyt.it.ogt.kq.common.gov.constant.examsys;

import com.hyt.it.ogt.kq.common.config.exception.KqException;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 * 考试系统请求Action枚举
 * </p>
 *
 * @author huangyh
 * @since 2021-07-19
 */
@Slf4j
@Getter
public enum ActionEnum {

    /**
     * 通用分隔符
     */
    POUND_SIGN("#", "井号"),
    VERTICAL_SIGN("|", "竖线"),
    COLON_SIGN(":", "冒号"),
    AND_SIGN("&", "与符"),
    COMMA_SIGN(",", "逗号"),
    SLASH_SIGN("/", "斜杠"),

    /**
     * 通用请求参数名
     */
    ACTION("Action", "通用请求参数名"),

    /**
     * 考前
     */
    GET_REGISTER_INFO("QueryFromRoom", "通过考点或考场编码查询考点或考场注册信息"),
    NEW_REGISTER_ROOM("NewRegisterRoom", "注册考场信息"),
    REGISTER_ROOM("RegisterRoom", "注册考场信息"),
    GET_EXAM_TASK_LIST("PostExamItem", "获取已启用的考试项目列表"),
    GET_TIME_BY_PLACE("GetPCByPlaceCode", "根据考点编号得到其下的考试批次及考场信息"),
    GET_BASE_PACKAGE("GetExamConfer", "下载基础包"),
    UPDATE_BASE_DATA_STATE("UpdateExamConfer", "更新基础包文件下载状态"),
    GET_TASK_CODE("PostItemCode", "获取已启用的考试项目编号"),
    GET_ROOM_PACKAGE("PostRoomData", "获取考场考务数据包"),
    UPDATE_ROOM_PACKAGE_STATE("UpdateKWPState", "考务包下载成功后更新考务包下载状态"),
    GET_PAPER_DATA("PostPaperData", "获取试卷包"),
    UPDATE_PAPER_DATA_STATE("UpdatePaperState", "试卷包下载成功后更新试卷包下载状态"),
    GET_PAPER_AUTHORIZATION_CODE("PostPaperCode", "获取试卷授权码"),
    UPDATE_PAPER_AUTHORIZATION_CODE_STATE("UpdatePaperCodeState", "获取试卷授权码成功后通知考务更新试卷授权码状态"),
    UPLOAD_TEST_REPORT("PutSimulateResult", "上传模拟测试报告"),
    UPDATE_CLOSURE("UpdateClosure", "上传封场信息"),
    GET_MONITOR_SETTING_BACKUP_PATH("PutMonitorSettingInfo", "获取上传监考机配置备份信息地址"),
    UPDATE_MONITOR_SETTING_BACKUP_STATE("UpdateMonitorSettingInfoUploadState", "更新上传监考端配置备份信息状态"),
    GET_MONITOR_SETTING("PostMonitorSettingInfo", "下载监考端配置备份信息"),
    UPDATE_MONITOR_SETTING_BACKUP_DOWNLOAD_STATE("UpdateMonitorSettingInfoDownloadState", "更新下载监考端配置备份信息状态"),
    EXAM_PACKAGE_SYNC("CoverExamInfo", "同步考试数据包"),
    GET_TEST_INVENTORY("PostSimulateItems", "下载测试项清单"),
    UPDATE_BACKUP_STATE("UpdateBackupState", "同步备份状态"),
    UPDATE_TEST_INVENTORY_STATE("UpdateSimulateItems", "更新下载模拟测试项清单结果"),

    /**
     * 考中
     */
    CHECK_EXAM_SYSTEM_CONNECTION("TestSysConnection", "测试考试系统能否正常连接考务系统"),
    GET_SERVER_TIME("GetServerTime", "获取服务器时间"),
    GET_CANDIDATE_INFO("QueryCandidateInfo", "获取考生信息(在线添加考生)"),
    UPDATE_EXAM_MONITOR("GetExamRoomStateInfo", "上报考场考试过程操作数据状态"),

    /**
     * 考后
     */
    GET_RESULT_UPLOAD_PATH("PutDapVaild", "校验是否可以上传考试结果，并获取上传路径"),
    VERIFY_RESULT("VerifyResultPackage", "校验考试结果是否上传成功"),
    UPDATE_RESULT_STATE("UpdateDapState", "上传考试结果成功后通知考务更新上传状态"),
    GET_RESIT_ROOM_PACKAGE("PostZKRoomData", "获取考场重考考务数据包"),
    UPDATE_RESIT_ROOM_PACKAGE_STATE("UpdateZKKWPState", "重考考务包下载成功后更新重考考务包下载状态"),
    POST_BEHAVIOR_ANALYSIS("PostBehaviorAnalysis", "上传行为分析"),

    /**
     * 其他
     */
    GET_HUAWEI_CLOUD_OBS_INFO("GetHuaweiCloudObsInfo", "获取华为云OBS信息"),

    ;

    private final String name;
    private final String remark;

    ActionEnum(String name, String remark) {
        this.name = name;
        this.remark = remark;
    }

    /**
     * 获取Action
     * @param name Action名称
     * @return Action枚举
     * @throws KqException Action不存在，抛出异常
     */
    public static ActionEnum getByName(String name) throws KqException {
        for (ActionEnum value : values()) {
            if (value.getName().equals(name)) {
                return value;
            }
        }
        //Action暂不支持
        log.error("Action ({}) 暂不支持", name);
        throw new KqException(-1, "Action暂不支持");
    }

}
